User:Technical 13/Scripts/Gadget-pageProtectionLevels.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Technical 13/Scripts/Gadget-pageProtectionLevels. |
var editLevel = mw.config.get('wgRestrictionEdit');
if(editLevel !== "" || typeof(editLevel) !== 'undefined' || editLevel !== null){
if ($.inArray('sysop', editLevel) >= 0){
editLevel = "full";
}
else if ($.inArray('autoconfirmed', editLevel) >= 0){
editLevel = "semi";
}
else if ($.inArray('templateeditor', editLevel) >= 0){
editLevel = "te";
} else {
editLevel = "none";
}
} else {
editLevel = "none";
}
var moveLevel = mw.config.get('wgRestrictionMove');
if(moveLevel !== "" || typeof(moveLevel) !== 'undefined' || moveLevel !== null){
if ($.inArray('sysop', moveLevel) >= 0){
moveLevel = "full";
}
else if ($.inArray('templateeditor', moveLevel) >= 0){
moveLevel = "te";
}
else if ($.inArray('autoconfirmed', moveLevel) >= 0){
moveLevel = "semi";
} else {
moveLevel = "none";
}
} else {
moveLevel = "none";
}
if(editLevel === "full" && moveLevel === "full"){
$('li#pt-userpage').before('<li>Full protection enabled</li>');
} else if(editLevel === "full" && moveLevel === "te"){
$('li#pt-userpage').before('<li>Full/TE protection enabled</li>');
} else if(editLevel === "full" && moveLevel === "semi"){
$('li#pt-userpage').before('<li>Full/Semi protection enabled</li>');
} else if(editLevel === "full" && moveLevel === "none"){
$('li#pt-userpage').before('<li>Full edit protection enabled</li>');
} else if(editLevel === "te" && moveLevel === "full"){
$('li#pt-userpage').before('<li>TE/Full protection enabled</li>');
} else if(editLevel === "semi" && moveLevel === "full"){
$('li#pt-userpage').before('<li>Semi/Full protection enabled</li>');
} else if(editLevel === "te" && moveLevel === "te"){
$('li#pt-userpage').before('<li>TE protection enabled</li>');
} else if(editLevel === "semi" && moveLevel === "semi"){
$('li#pt-userpage').before('<li>Semi protection enabled</li>');
} else if(editLevel === "semi" && moveLevel === "none"){
$('li#pt-userpage').before('<li>Semi edit protection enabled</li>');
} else if(editLevel === "none" && moveLevel === "full"){
$('li#pt-userpage').before('<li>Full move protection enabled</li>');
} else if(editLevel === "none" && moveLevel === "te"){
$('li#pt-userpage').before('<li>TE move protection enabled</li>');
} else if(editLevel === "none" && moveLevel === "semi"){
$('li#pt-userpage').before('<li>Semi move protection enabled</li>');
} else {
/* Do nothing because there is no protection */
}
/* Protection icons
// Full
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#indef" title="This high-risk template is permanently protected from editing."><img alt="Page permanently protected" src="//upload.wikimedia.org/wikipedia/en/thumb/4/48/Padlock-red.svg/20px-Padlock-red.svg.png" srcset="//upload.wikimedia.org/wikipedia/en/thumb/4/48/Padlock-red.svg/30px-Padlock-red.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/4/48/Padlock-red.svg/40px-Padlock-red.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a></li>');
// TE
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#template" title="This high-risk template is permanently protected from editing."><img alt="Permanently protected template" src="//upload.wikimedia.org/wikipedia/commons/thumb/7/70/Padlock-pink.svg/20px-Padlock-pink.svg.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/7/70/Padlock-pink.svg/30px-Padlock-pink.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/7/70/Padlock-pink.svg/40px-Padlock-pink.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a></li>');
// Semi
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#semi" title="This article is semi-protected indefinitely in response to an ongoing high risk of vandalism."><img alt="Page semi-protected" src="//upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/20px-Padlock-silver.svg.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/30px-Padlock-silver.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/40px-Padlock-silver.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a></li>');
// PC1
<div id="mw-fr-revisiontag" class="flaggedrevs_short plainlinks noprint"><div class="flaggedrevs_short_basic"><img class="flaggedrevs-icon" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/doc-magnify.png" alt="Changes must be reviewed before being displayed on this page." title="Changes must be reviewed before being displayed on this page."><b><a href="/wiki/Wikipedia:Pending_changes" title="Wikipedia:Pending changes">Accepted (latest)</a></b><img id="mw-fr-revisiontoggle" class="fr-toggle-arrow" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/arrow-down.png" style="display: inline;" alt="show/hide details"></div><a href="/wiki/Wikipedia:Protection_policy#pc1" title="All edits by unregistered and new users are subject to review."><img alt="Page protected with pending changes level 1" src="//upload.wikimedia.org/wikipedia/commons/thumb/2/28/Padlock-silver-light.svg/20px-Padlock-silver-light.svg.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/2/28/Padlock-silver-light.svg/30px-Padlock-silver-light.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/2/28/Padlock-silver-light.svg/40px-Padlock-silver-light.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a>
// PC2
<div id="mw-fr-revisiontag" class="flaggedrevs_short plainlinks noprint"><div class="flaggedrevs_short_basic"><img class="flaggedrevs-icon" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/doc-magnify.png" alt="Changes must be reviewed before being displayed on this page." title="Changes must be reviewed before being displayed on this page."><b><a href="/wiki/Wikipedia:Pending_changes" title="">Accepted (latest)</a></b><img id="mw-fr-revisiontoggle" class="fr-toggle-arrow" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/arrow-down.png" style="display: inline;" alt="show/hide details"></div><div id="mw-fr-revisiondetails-wrapper" style="position:relative;"><div id="mw-fr-revisiondetails" class="flaggedrevs_short_details" style="display: none;">This is the <a href="/wiki/Wikipedia:Pending_changes" title="Wikipedia:Pending changes">latest accepted revision</a>, <a class="external text" href="//en.wikipedia.org/w/index.php?title=Special:Log&type=review&page=Conventional_PCI">accepted</a> on <i>June 14, 2014</i>.</div></div></div><a title="All edits by users who are not reviewers or administrators are subject to review." href="/wiki/Wikipedia:Protection_policy#pc2"><img width="20" height="20" data-file-height="128" data-file-width="128" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Padlock-…thumb/a/a9/Padlock-orange.svg/40px-Padlock-orange.svg.png 2x" src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Padlock-orange.svg/20px-Padlock-orange.svg.png" alt="Page protected with pending changes level 2"></img></a>
// Move
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#move" title="This article is move-protected."><img alt="Page move-protected" src="//upload.wikimedia.org/wikipedia/en/thumb/5/58/Padlock-olive.svg/20px-Padlock-olive.svg.png" srcset="//upload.wikimedia.org/wikipedia/en/thumb/5/58/Padlock-olive.svg/20px-Padlock-olive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/5/58/Padlock-olive.svg/30px-Padlock-olive.svg.png 2x" data-file-width="128" data-file-height="128" height="15" width="15"></a></li>');
// Create
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#create" title="This article is create-protected."><img alt="Page create-protected" src="http://upload.wikimedia.org/wikipedia/en/a/a0/Padlock-skyblue.svg" srcset="//upload.wikimedia.org/wikipedia/en/thumb/a/a0/Padlock-skyblue.svg/20px-Padlock-skyblue.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/a/a0/Padlock-skyblue.svg/30px-Padlock-skyblue.svg.png 2x" data-file-width="128" data-file-height="128" height="15" width="15"></a></li>');
*/